using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Tsetup Test Class
  /// </summary>
  [TestClass]
  public class TestTsetup
  {
    #region Class Variables
    private CdoPrms<DOTsetup>		m_Tsetup;
    private CdoPrmsList<DOTsetup>	m_AllTsetup;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTsetup()
    {
      // Create the data objects
      this.m_Tsetup	= new CdoPrms<DOTsetup>();
      this.m_AllTsetup	= new CdoPrmsList<DOTsetup>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Tsetup data objects
    /// </summary>
    [TestMethod]
    public void TsetupRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTsetup.DataObject = new DOTsetup();
      this.m_AllTsetup.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTsetup.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTsetup.Errors.Count > 0) { Assert.Fail(this.m_AllTsetup.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Tsetup
    /// </summary>
    [TestMethod]
    public void TsetupCreate()
    {
      // Set up the data object for creation
      this.m_Tsetup.DataObject.MAXDAYS = 12.3M;
      this.m_Tsetup.DataObject.MAXREQ = 12.3M;
      this.m_Tsetup.DataObject.SENDMAIL = false;
      this.m_Tsetup.DataObject.SMTPIP = 'b';
      this.m_Tsetup.DataObject.SENDEREMAIL = 'b';
      this.m_Tsetup.DataObject.SENDERNAME = 'b';
      this.m_Tsetup.DataObject.SENDSTSERR = false;
      this.m_Tsetup.DataObject.SENDSTSTO = 'b';
      this.m_Tsetup.DataObject.RETWARN = false;
      this.m_Tsetup.DataObject.PICKFOLDER = 12.3M;
      this.m_Tsetup.DataObject.QCLETBODY = new byte[] { 1, 2, 3 };
      this.m_Tsetup.DataObject.ORDERNO = 10;
      this.m_Tsetup.DataObject.ORDERTOEMAIL = 'b';
      this.m_Tsetup.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Tsetup.PerformAction())
      {
        // Assert the errors
        if (this.m_Tsetup.Errors.Count > 0) { Assert.Fail(this.m_Tsetup.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Tsetup
    /// </summary>
    [TestMethod]
    public void TsetupRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Tsetup.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Tsetup.DataObject.PICKLIMIT = 12.3M;
      }

      // Set up the data object action for retrieval
      this.m_Tsetup.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Tsetup.PerformAction())
      {
        // Assert the errors
        if (this.m_Tsetup.Errors.Count > 0) { Assert.Fail(this.m_Tsetup.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
